<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">
    <!--图网站标-->
    <!--<link rel="icon" href="../../favicon.ico">-->

    <title>校园用户管理----注册页面</title>


    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">

    <link href="/fw/static/css/ie10-viewport-bug-workaround.css" rel="stylesheet">

    <link href="/fw/static/css/signin.css" rel="stylesheet">

    <script src="/fw/static/js/ie-emulation-modes-warning.js"></script>

    <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>

</head>

<body>

<p class="form-signin-heading">学生注册页面</p>
<div class="container">
    <div class="form-signin">
        <input type="text" id="inputUsername" class="form-control" placeholder="*学号" required autofocus>
        <input type="password" id="inputPassword" class="form-control" placeholder="*密码" required>
        <input type="password" id="checkPassword" class="form-control" placeholder="*确认密码" required>
        <input type="text" id="inputRealName" class="form-control" placeholder="*真实姓名" required>
        <label for="inputAge" class="sr-only">年龄</label>
        <input type="number" id="inputAge" class="form-control" placeholder="*年龄" required>
        <label class="radio-inline">
            <input type="radio" name="inlineRadioOptions" id="inlineRadio1" value="男" checked> 男
        </label>
        <label class="radio-inline">
            <input type="radio" name="inlineRadioOptions" id="inlineRadio2" value="女"> 女
        </label>
        <input type="text" id="inputAddress" class="form-control" placeholder="*家庭住址" required>
        <input type="text" id="inputClass" class="form-control" placeholder="*专业班级" required>
        <button class="btn btn-lg btn-primary btn-block" type="submit" id="formRegister">提交</button>
    </div>

</div> <!-- /container -->
</body>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="/fw/static/Jquery/jquery-2.2.3.min.js"></script>
<script src="/fw/static/Jquery/jquery.js"></script>
<script src="/fw/static/js/ie10-viewport-bug-workaround.js"></script>
<script src="/fw/static/Jquery/jquery.cookie.js"></script>
<script>
    $("#formRegister").click(function () {
        var user = $("#inputUsername").val().trim();
        var pwd = $("#inputPassword").val().trim();
        var cpwd = $("#checkPassword").val().trim();
        var realName = $("#inputRealName").val().trim();
        var sex = $("input:radio[name='inlineRadioOptions']:checked").val();
        var inputClass = $("#inputClass").val().trim();
        var inputAddress = $("#inputAddress").val().trim();
        var age = $("inputAge").val();
        if(!(user!=""&&pwd!=""&&cpwd!=""&&realName!=""&&inputClass!=""&&inputAddress!=""&&sex!="")){
            alert("请填写必填内容!");
            return false;
        }
        if(pwd != cpwd){
            alert("两次密码不一致");
            return false;
        }
        $.ajax({
            type: "POST",
            url: "/fw/login/registerStu",
            data: {"username": user, "password": pwd,"realName":realName,
                "sex":sex,"grade":inputClass,"address":inputAddress,
                "schoolTime":new Date(),"age":age
            },
            success: function (dataJson) {
                var jsonObj = $.parseJSON(dataJson);
                if (jsonObj.status == 0) {
                    alert("注册成功!");
                    setTimeout(function (args) {
                        window.location.href="/fw/login";
                    },1000);
                } else if(jsonObj.status == 3){
                    alert(jsonObj.msg);
                }else{
                    alert(jsonObj.msg);
                }
            },
            error: function (data) {
                var jsonObj = $.parseJSON(dataJson);
                alert(dataJson.msg);
            }
        })
    });
</script>
</html>
